import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

// 防止重复点击报错
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/dashboard'
        },
        {
            path: '/',
            component: () => import(/* webpackChunkName: "home" */ '../components/common/Home.vue'),
            meta: { title: '自述文件' },
            children: [
                {
                    path: '/dashboard',
                    component: () => import(/* webpackChunkName: "dashboard" */ '../components/page/Dashboard.vue'),
                    meta: { title: '系统首页' }
                },
                {
                    path: '/icon',
                    component: () => import(/* webpackChunkName: "icon" */ '../components/page/Icon.vue'),
                    meta: { title: '自定义图标' }
                },
                {
                    path: '/table',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/BaseTable.vue'),
                    meta: { title: '用户信息' }
                },
                {
                    path: '/score',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/ScoreTable.vue'),
                    meta: { title: '成绩管理' }
                },
                {
                    path: '/question',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/QuestionTable.vue'),
                    meta: { title: '题库列表' }
                },
                {
                    path: '/add_question',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/AddQuestionTable.vue'),
                    meta: { title: '题目列表' }
                },
                {
                    path: '/contest',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/ContestTable.vue'),
                    meta: { title: '竞赛列表' }
                },
                {
                    path: '/collegeContest',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/collegeContest.vue'),
                    meta: { title: '学院竞赛' }
                },
                {
                    path: '/collegeStudentContest',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/collegeStudentContest.vue'),
                    meta: { title: '学院学生竞赛' }
                },
                {
                    path: '/notice',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/NoticeTable.vue'),
                    meta: { title: '公告列表' }
                },
                {
                    path: '/answerContest',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/AnswerContest.vue'),
                    meta: { title: '竞赛答题' }
                },
                {
                    path: '/question_type',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/QuestionType.vue'),
                    meta: { title: '答题练习' }
                },
                {
                    path: '/practice',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/QuestionPractice.vue'),
                    meta: { title: '答题练习' }
                },
                {
                    path: '/analysis',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/AIAnalysis.vue'),
                    meta: { title: '智能分析' }
                },
                {
                    path: '/staticPriority',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/autoTest/staticPriority.vue'),
                    meta: { title: '优先级静态划分' }
                },
                {
                    path: '/dynamicPriority',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/autoTest/dynamicPriority.vue'),
                    meta: { title: '优先级动态调整' }
                },
                {
                    path: '/watchStatus',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/autoTest/watchStatus.vue'),
                    meta: { title: '状态监控' }
                },
                {
                    path: '/contest_records',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/ContestRecords.vue'),
                    meta: { title: '参赛记录' }
                },
                {
                    path: '/question_records',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/QuestionRecords.vue'),
                    meta: { title: '答题记录' }
                },
                {
                    path: '/examMsg',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/examMsg.vue'),
                    meta: { title: '竞赛详情' }
                },
                {
                    path: '/tabs',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/Tabs.vue'),
                    meta: { title: 'tab选项卡' }
                },
                {
                    path: '/contactUs',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/ContactUs.vue'),
                    meta: { title: '联系作者' }
                },
                {
                    path: '/form',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/BaseForm.vue'),
                    meta: { title: '基本表单' }
                },
                {
                    // 富文本编辑器组件
                    path: '/editor',
                    component: () => import(/* webpackChunkName: "editor" */ '../components/page/VueEditor.vue'),
                    meta: { title: '富文本编辑器' }
                },
                {
                    // markdown组件
                    path: '/markdown',
                    component: () => import(/* webpackChunkName: "markdown" */ '../components/page/Markdown.vue'),
                    meta: { title: 'markdown编辑器' }
                },
                {
                    // 批量上传用户数据
                    path: '/upload',
                    component: () => import(/* webpackChunkName: "upload" */ '../components/page/Upload.vue'),
                    meta: { title: '批量上传' }
                },
                {
                    // 批量上传题目数据
                    path: '/uploadQuestion',
                    component: () => import(/* webpackChunkName: "upload" */ '../components/page/UploadQuestion.vue'),
                    meta: { title: '批量上传' }
                },
                {
                    // 批量上传竞赛数据
                    path: '/uploadContest',
                    component: () => import(/* webpackChunkName: "upload" */ '../components/page/UploadContest.vue'),
                    meta: { title: '批量上传' }
                },
                {
                    // vue-schart组件
                    path: '/charts',
                    component: () => import(/* webpackChunkName: "chart" */ '../components/page/BaseCharts.vue'),
                    meta: { title: 'schart图表' }
                },
                {
                    // 拖拽列表组件
                    path: '/drag',
                    component: () => import(/* webpackChunkName: "drag" */ '../components/page/DragList.vue'),
                    meta: { title: '拖拽列表' }
                },
                {
                    // 拖拽Dialog组件
                    path: '/dialog',
                    component: () => import(/* webpackChunkName: "dragdialog" */ '../components/page/DragDialog.vue'),
                    meta: { title: '拖拽弹框' }
                },
                {
                    // 国际化组件
                    path: '/i18n',
                    component: () => import(/* webpackChunkName: "i18n" */ '../components/page/I18n.vue'),
                    meta: { title: '国际化' }
                },
                {
                    // 权限页面
                    path: '/permission',
                    component: () => import(/* webpackChunkName: "permission" */ '../components/page/Permission.vue'),
                    meta: { title: '权限测试', permission: true }
                },
                {
                    path: '/404',
                    component: () => import(/* webpackChunkName: "404" */ '../components/page/404.vue'),
                    meta: { title: '404' }
                },
                {
                    path: '/403',
                    component: () => import(/* webpackChunkName: "403" */ '../components/page/403.vue'),
                    meta: { title: '403' }
                },
                {
                    path: '/personalInfo',
                    component: () => import(/* webpackChunkName: "personalInfo" */ '../components/page/PersonalInfo.vue'),
                    meta: { title: '个人中心' }
                }
            ]
        },
        {
            path: '/login',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/Login.vue'),
            meta: { title: '登录' }
        },
        {
            path: '/register',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/Register.vue'),
            meta: { title: '注册' }
        },
        {
            path: '*',
            redirect: '/404'
        }
    ]
});
